<!DOCTYPE html>
<html lang="en">
<head>
    <title>编辑汇票信息</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <style type="text/css">
        .leftFilter {
            float: left;
            text-align: left;
            margin-right: 5px;
        }

        .clickable {
            color: #489EF1;;
            cursor: pointer;
            text-align: left;
            font-weight: bold;
        }

        .td {
            text-align: center;
        }
    </style>
</head>
<body>
<section class="content" id="list">
    <table class="table table-bordered" style="max-width: 750px;margin: -1px 0">
        <tbody>
        <tr>
            <td style="width: 100px;text-align: center;background: #d2e8fd;background: #d2e8fd">出票人</td>
            <td>
                <input v-model="jsonData.drawerName" style="width: 100%;border: none" />
            </td>
            <td style="width: 100px;text-align: center;background: #d2e8fd">出票银行</td>
            <td>
                <input v-model="jsonData.drawerBank" style="width: 100%;border: none" />
            </td>
            <td style="width: 100px;text-align: center;background: #d2e8fd">收入项目</td>
            <td>
                <input v-model="jsonData.incomeProject" style="width: 100%;border: none" />
            </td>
        </tr>
        <tr>
            <td style="width: 100px;text-align: center;background: #d2e8fd">出票日期</td>
            <td >
                <input type="text" v-model="jsonData.drawerDate" @focus="showDatePicker($event,'drawerDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
            </td>
            <td style="width: 100px;text-align: center;background: #d2e8fd">到期日期</td>
            <td >
                <input type="text" v-model="jsonData.dueDate" @focus="showDatePicker($event,'dueDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
            </td>
            <td style="width: 100px;text-align: center;background: #d2e8fd">汇票号码</td>
            <td>
                <input v-model="jsonData.debitsNo" style="width: 100%;border: none" />
            </td>
        </tr>
        <tr>
            <td style="width: 100px;text-align: center;background: #d2e8fd">金额</td>
            <td>
                <input v-model="jsonData.money" style="width: 100%;border: none" />
            </td>
            <td style="width: 100px;text-align: center;background: #d2e8fd">收票日期</td>
            <td >
                <input type="text" v-model="jsonData.invoiceDate" @focus="showDatePicker($event,'invoiceDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
            </td>
            <td style="width: 100px;text-align: center;background: #d2e8fd">是否背书</td>
            <td style="background: #F8F8F8">
                <select v-model="jsonData.endorseFlag" style="width: 100%;float: left;border: none;background: none">
                    <option value="0" selected>否</option>
                    <option value="1">是</option>
                </select>
            </td>
        </tr>
        <tr v-if="jsonData.endorseFlag==1">
            <td style="text-align: center;background: #d2e8fd">背书方式</td>
            <td colspan="5">
                托收 <input type="radio" value="0" v-model="jsonData.endorseMode">&nbsp;&nbsp;&nbsp;&nbsp;
                贴现 <input type="radio" value="1" v-model="jsonData.endorseMode">&nbsp;&nbsp;&nbsp;&nbsp;
                转出 <input type="radio" value="2" v-model="jsonData.endorseMode">&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
        <template v-if="jsonData.endorseFlag==1 && jsonData.endorseMode==0">
            <tr>
                <td style="width: 100px;text-align: center;background: #d2e8fd">托收银行</td>
                <td>
                    <select v-model="jsonData.fkBankCardId" style="width: 100%;float: left;border: none;background: none">
                        <template v-for="(bank,index) in bankList">
                            <option :value="bank.id" v-if="bank.id=jsonData.fkBankCardId" selected>{{bank.bankName}}</option>
                            <option :value="bank.id" v-else>{{bank.bankName}}</option>
                        </template>
                    </select>

                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">背书日期</td>
                <td >
                    <input type="text" v-model="jsonData.endorseDate" @focus="showDatePicker($event,'endorseDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">托收是否到账</td>
                <td style="background: #F8F8F8">
                    <select v-model="jsonData.collectionArriveFlag" style="width: 100%;float: left;border: none;background: none">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 100px;text-align: center;background: #d2e8fd">到账日期</td>
                <td >
                    <input type="text" v-model="jsonData.collectionArriveDate" @focus="showDatePicker($event,'collectionArriveDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">是否质押</td>
                <td style="background: #F8F8F8">
                    <select v-model="jsonData.impawnFLAg" style="width: 100%;float: left;border: none;background: none">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">备注</td>
                <td>
                    <input v-model="jsonData.remark" style="width: 100%;border: none" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center;background: #d2e8fd">支出项目</td>
                <td colspan="5">
                    <input v-model="jsonData.outcomeProject" style="width: 100%;border: none" />
                </td>
            </tr>
        </template>

        <template v-if="jsonData.endorseFlag==1 && jsonData.endorseMode==1">
            <tr>
                <td style="width: 100px;text-align: center;background: #d2e8fd">贴现银行</td>
                <td>
                    <input v-model="jsonData.discountBank" style="width: 100%;border: none" />
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">贴现日期</td>
                <td >
                    <input type="text" v-model="jsonData.discountDate" @focus="showDatePicker($event,'discountDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">贴现息</td>
                <td>
                    <input v-model="jsonData.discountInterest" style="width: 100%;border: none" />
                </td>
            </tr>
            <tr>
                <td style="width: 100px;text-align: center;background: #d2e8fd">贴现金额</td>
                <td>
                    <input v-model="jsonData.discountMoney" style="width: 100%;border: none" />
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">是否质押</td>
                <td style="background: #F8F8F8">
                    <select v-model="jsonData.impawnFLAg" style="width: 100%;float: left;border: none;background: none">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">备注</td>
                <td>
                    <input v-model="jsonData.remark" style="width: 100%;border: none" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center;background: #d2e8fd">支出项目</td>
                <td colspan="5">
                    <input v-model="jsonData.outcomeProject" style="width: 100%;border: none" />
                </td>
            </tr>
        </template>

        <template v-if="jsonData.endorseFlag==1 && jsonData.endorseMode==2">
            <tr>
                <td style="width: 100px;text-align: center;background: #d2e8fd">客户名称</td>
                <td>
                    <input v-model="jsonData.customerName" style="width: 100%;border: none" />
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">背书日期</td>
                <td>
                    <input type="text" v-model="jsonData.endorseDate" @focus="showDatePicker($event,'endorseDate')" style="width: 100%;border: none;background: url(../../../dist/img/date.png) no-repeat right;">
                </td>
                <td style="width: 100px;text-align: center;background: #d2e8fd">是否质押</td>
                <td style="background: #F8F8F8">
                    <select v-model="jsonData.impawnFLAg" style="width: 100%;float: left;border: none;background: none">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 100px;text-align: center;background: #d2e8fd">备注</td>
                <td>
                    <input v-model="jsonData.remark" style="width: 100%;border: none" />
                </td>
                <td style="text-align: center;background: #d2e8fd">支出项目</td>
                <td colspan="3">
                    <input v-model="jsonData.outcomeProject" style="width: 100%;border: none" />
                </td>
            </tr>
        </template>

        </tbody>
    </table>

    <div style="height:30px;line-height:30px;text-align: center;z-index:999;padding-top:5px;margin-bottom: 15px">
        <input type="button" value="保存" @click="save()" class="btn oaBtn btn-sm" style="margin-top:5px;">
    </div>
    </div>
    <!-- /.box-body -->
</section>
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/select2/select2.full.min.js"></script>
<script type="text/javascript">
    Vue.directive('select2', {
        inserted: function (el, binding, vnode) {
            var options = binding.value || {};

            $(el).select2(options).on("select2:select", function (e) {
                el.dispatchEvent(new Event('change', {target: e.target})); //说好的双向绑定，竟然不安套路
            });
        },
        update: function (el, binding, vnode) {
            $(el).trigger("change");
        }
    });
    var app = new Vue({
        el: '#list',
        data: {
            jsonData:{
                fkBankCardId:"",
                drawerName:"",
                drawerBank:"",
                incomeProject:"",
                drawerDate:"",
                dueDate:"",
                debitsNo:"",
                money:"",
                invoiceDate:"",
                endorseFlag:"",
                endorseMode:"",
                endorseDate:"",
                collectionArriveFlag:"",
                collectionArriveDate:"",
                impawnFlag:"",
                remark:"",
                outcomeProject:"",
                discountBank:"",
                discountDate:"",
                discountInterest:"",
                discountMoney:"",
                customerName:"",
                updateUserId:getCurrentUser().id,
                updateTime:"",
                fkCompanyId:getCurrentUser().companyId
            },
            time:"",
            bankList:[]
        },
        methods: {
            save:function () {
                if (this.jsonData.drawerName.length==0){
                    alert("请填写出票人");
                    return;
                }else if (this.jsonData.drawerBank.length==0){
                    alert("请填写出票银行");
                    return;
                }else if (this.jsonData.incomeProject.length==0){
                    alert("请填写收入项目");
                    return;
                }else if (this.jsonData.drawerDate.length==0){
                    alert("请填写出票日期");
                    return;
                }else if (this.jsonData.dueDate.length==0){
                    alert("请填写到期日期");
                    return;
                }else if (this.jsonData.debitsNo.length==0){
                    alert("请填写汇票号码");
                    return;
                }else if (this.jsonData.money.length==0){
                    alert("请填写金额");
                    return;
                }else if (this.jsonData.invoiceDate.length==0){
                    alert("请填写收票日期");
                    return;
                }
                $.wyui.postMethod('/bankDebitsFacade/save.json', this.jsonData, function (data) {
                    alert("操作成功");
                    parent.refresh();
                    var api = frameElement.api, W = api.opener;
                    api.close();
                });
            },
            showDatePicker: function (e,type) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.jsonData[type] = dp.cal.getNewDateStr();
                        return true;
                    },
                });
                $(e.target).blur();
            }
        },

        mounted: function () {
            var that=this;
            $.wyui.postMethod('/bankCard/getBankCardList.json', {fkCompanyId:getCurrentUser().companyId,useStatus:1}, function (data) {
                console.log(data);
                that.bankList=data;
                that.jsonData.fkBankCardId=that.bankList[0].id;
            });

            var id = $.wyui.page.urlParams.id;
            if (id!=null&&id.length>0){
                $.wyui.postMethod('/bankDebitsFacade/getById.json', {id:id}, function (data) {
                    console.log(data);
                    that.jsonData = data;
                    that.jsonData.fkBankCardId=that.bankList[0].id;
                });
            }
        }
    });


</script>

</body>
</html>